<template>
  <div class="">
    <el-dialog title="历史状态" :visible.sync="dialogVisible" width="50%">
      <QueryTable
        :tableConfiguration="tableConfiguration"
        :displayContent="displayContent"
        :formData="formData"
        ref="queryTable"
        :isPop="true"
        :api="getTableServe"
      >
        <template v-slot:status="{ scope }">
          <el-tag type="success" v-if="scope.row.status == 1">在线</el-tag>
          <el-tag type="info" v-if="scope.row.status == 2">离线</el-tag>
        </template>
        <template v-slot:createTime="{ scope }">
          {{ timerChange(scope.row.createTime) }}
        </template>
      </QueryTable>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import moment from 'moment';
import QueryTable from '@/components/queryTable/index.vue';

import { sysdeviceslist, senseLinkopendoor } from '@/api/comment/EquipmentList.js';

export default {
  components: {
    QueryTable
  },
  data() {
    return {
      dialogVisible: false,
      getTableServe: sysdeviceslist,
      //配置文件
      displayContent: {
        height: '45vh',
        indexFixed: true,
        selectionFixed: true,
        selection: false,
        index: true,
        paginationShow: true
      },
      formData: {}, //传给后端的参数
      tableConfiguration: [
        {
          prop: 'status',
          label: '设备状态',
          align: 'center',
          sockets: true
        },
        {
          prop: 'createTime',
          label: '时间',
          align: 'center',
          sockets: true
        }
      ]
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    open(data) {
      this.dialogVisible = true;
      this.formData.sn = data.serialNumber;
      this.$nextTick(() => {
        this.$refs.queryTable.handleCurrentChange(1);
      });
    },
    timerChange(data) {
      if (data) {
        return moment.utc(data).format('YYYY-MM-DD HH:mm:ss');
      }
    }
  }
};
</script>

<style lang="scss" scoped></style>
